/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



import JaCoP.core.Store;
import JaCoP.core.Variable;
import JaCoP.search.DepthFirstSearch;
import JaCoP.search.IndomainMin;
import JaCoP.search.Search;
import JaCoP.search.SelectChoicePoint;
import JaCoP.search.SimpleSelect;
import java.util.ArrayList;

/**
 *
 * @author Administrator
 */
public class searchOptimal {

    /**
	 * It contains all variables used within a specific example.
	 */
	public ArrayList<Variable> vars;
	
	/**
	 * It specifies the cost function, null if no cost function is used.
	 */
	public Variable cost;
	
	/**
	 * It specifies the constraint store responsible for holding information 
	 * about constraints and variables.
	 */
	public Store store;
	
	/**
	 * It specifies the search procedure used by a given example.
	 */
	public Search search;	
	
	/**
	 * It specifies a standard way of modeling the problem.
	 */
    public boolean searchOptimal() {

		long T1, T2;
		T1 = System.currentTimeMillis();

		SelectChoicePoint select = new SimpleSelect(vars.toArray(new Variable[1]), null,
				new IndomainMin());

		search = new DepthFirstSearch();

		boolean result = search.labeling(store, select, cost);

		if (result)
			store.print();

		T2 = System.currentTimeMillis();

		//System.out.println("\n\t*** Execution time = " + (T2 - T1) + " ms");

		return result;

	}
}
